﻿/*
 *********************************************************************
 *    Management Extensions for Windows Windows Server AppFabric     *
 *********************************************************************
 *    Author    : Fatih Boy [fatih@enterprisecoding.com]             *
 *    Web site  : http://www.enterprisecoding.com                    *
 *********************************************************************
 *    License   : GNU Library General Public License (LGPL)          * 
 *********************************************************************
 */

using Microsoft.Web.Management.Client;
using System.Collections;
using Microsoft.Web.Management.Server;

namespace Com.Enterprisecoding.AppFabric.Extensions.Client.Pages.Cache.Accounts {
    internal sealed class CacheAccountServiceProxy : ModuleServiceProxy {
        public CacheAccountEntry[] GetAllowedClientAccounts() {
            var invocationResult = base.Invoke("InvokeCacheAccountServiceMethod", "GetAllowedClientAccounts", new object[0]) as ArrayList;

            var result = new CacheAccountEntry[invocationResult.Count];
            for (int i = 0; i < invocationResult.Count; i++) {
                result[i] = ResultObjectWrapper.CreateInstace<CacheAccountEntry>(invocationResult[i] as PropertyBag);
            }

            return result;
        }

        public void GrantCacheAllowedClientAccount(string accountName, bool force) {
            base.Invoke("InvokeCacheAccountServiceMethod", "GrantCacheAllowedClientAccount", new object[]{accountName, force});
        }

        public void RevokeCacheAllowedClientAccount(string accountName) {
            base.Invoke("InvokeCacheAccountServiceMethod", "RevokeCacheAllowedClientAccount", new object[] { accountName });
        }
    }
}